<template>
	<jk-dialog
		v-model="showDialog"
		title="详情-保养任务"
		width="800px"
		append-to-body
		:show-close-btn="true"
		:show-confirm-btn="false"
		:show-cancel-btn="false"
		@on-close="onVisibleChange(false)"
		@on-visible-change="onVisibleChange"
	>
		<el-form ref="ruleForm" :model="ruleForm" label-width="100px" :show-message="false">
			<div class="margin-bottom-4">
				<el-tag type="primary" effect="plain" class="">
					<span class="el-icon-tickets item-gap"></span>
					<span>基本信息</span>
				</el-tag>
			</div>
			<jk-card>
				<el-row>
					<el-col :span="12">
						<el-form-item class="margin-bottom-10" label="派工日期">
							<span class="read-only-2">{{ ruleForm.belongDate }}</span>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item class="margin-bottom-10" label="设备名称">
							<span class="read-only-2">{{ ruleForm.machineName }}</span>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item class="margin-bottom-10" label="保养项目">
							<span class="read-only-2">{{ ruleForm.upkeepItemName }}</span>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item class="margin-bottom-10" label="保养类别">
							<span class="read-only-2">{{ ruleForm.upkeepTypeName }}</span>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item class="margin-bottom-10" label="保养周期">
							<span class="read-only-2">{{ transferCircleUnit(ruleForm) }}</span>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item class="margin-bottom-10" label="上次保养时间">
							<span class="read-only-2">{{ ruleForm.lastUpkeepEndTime }}</span>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item class="margin-bottom-10" label="计划单号">
							<span class="read-only-2">{{ ruleForm.jobCode }}</span>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item class="margin-bottom-10" label="派工单号">
							<span class="read-only-2">{{ ruleForm.dispatchCode }}</span>
						</el-form-item>
					</el-col>
				</el-row>
			</jk-card>
			<jk-divider-card title="计划信息" icon="el-icon-date" placement="center" class="margin-top-20 margin-bottom-10">
				<el-row>
					<el-col :span="12">
						<el-form-item class="margin-bottom-10" label="计划保养时间">
							<span class="read-only-2">{{ ruleForm.planUpkeepTime }}</span>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item class="margin-bottom-10" label="保养人员">
							<span class="read-only-2">{{ ruleForm.cycleMax }}</span>
						</el-form-item>
					</el-col>
				</el-row>
			</jk-divider-card>
		</el-form>
	</jk-dialog>
</template>

<script>
    import upkeepMixin from '../upkeepItemPlan/upkeep';

    export default {
        mixins: [upkeepMixin],
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            dataItem: {
                type: Object,
                default() {
                    return {};
                }
            }
        },
        data() {
            return {
                showDialog: false,
                ruleForm: {}
            };
        },
        methods: {
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                }
            }
        },
        watch: {
            dialogState(newVal) {
                this.showDialog = newVal;
                if (newVal) {
                    this.ruleForm = this.dataItem ? JSON.parse(JSON.stringify(this.dataItem)) : {};
                }
            }
        }
    };
</script>
